

/*
* String
* 1.字符串的长度.length()
* 2.字符串的比较是否相等 .equals() 返回一个布尔值
* 3.字符串比较大小 .compareTo() 分大小写 compareToIgnoreCase()不分大小写 返回一个整型
* 4.查找字符串
* (1)charAt()返回下标处的字母 否则则报异常
* (2)indexOf()返回字符(字符串(第一个字符的下标))所处的下标 第一次的 没有则-1
* (3)lastIndexOf() 反过来实现indexOf的功能
* 4.字符串和数值之前的转换
* (1)使用Integer.parseInt(str)(字符串转数字) 用一个整型的变量来接收 其他类似只需换用包装类即可
* (2)使用String.valueOf()来实现数字转字符串
* 5.大小的转换
* (1)大写用toUpperCase()
* (2)小写用toLowerCase()
* 6.字符转数组 toCharArray()
* 7.字符串的替换replace()
* 8.字符串的拆分split()
* (1)以+ - * / .  得加上转义字符"\\."
* (2)如果想以多个分割符分割中间加| " |$"
* (3)多次分割
* 9.字符串的截取substring()
* (1)从指定下标截取到尾部
* (2)截取部分
* 10.trim()去除字符串两边的空格
*
* */

import java.util.Arrays;
import java.util.Locale;

public class Test {

    public static void main(String[] args) {
        String str5 = "name=zhangSan&age=19";
        String str = str5.substring(5);
        String str1 = str5.substring(5,9);
        System.out.println(str);
        System.out.println(str1);
    }
    public static void main6(String[] args) {
        String str = "good morning first day";
        String str3 = "192.15.63.25";
        String str4 = "192.15&63*25";
        String str5 = "name=zhangSan&age=19";
        String[] str6 = str5.split("&");
        for (String x:str6
             ) {
            String[] xx = x.split("=");
            for (String y:xx
                 ) {
                System.out.println(y);
            }

        }
        String[] str1 = str4.split("\\.|&|\\*");
        String[] str2 = str.split(" ",3);
        for (String x:str1
             ) {
            System.out.println(x);
        }
    }
    public static void main5(String[] args) {
        String str = "adasadadaffssadaf";
        String ret = str.replace('a','g');
        String ret1 = str.replace("ad","fff");
        String ret2 = str.replaceAll("ad","ggg");
        System.out.println(ret);
        System.out.println(ret1);
        System.out.println(ret2);
    }

    public static void main4(String[] args) {
        String str = "hello";
        char[] chars =str.toCharArray();
        for (char x: chars
             ) {
            System.out.println(x);
        }
    }

    public static void main3(String[] args) {
        String str = "Hello";
        System.out.println(str.toUpperCase());
        System.out.println(str.toLowerCase());
    }
    public static void main2(String[] args) {
        int date = 123;
        char[] ch = {'a','b','c'};
        int[] array = {1,2,3,4,5,6};

        String str = String.valueOf(date);
        System.out.println(str);
        System.out.println(Arrays.toString(ch));
    }
    public static void main1(String[] args) {

        String str = "Hello";
        String str2 = "hello";
        String str3 = "123";
        int date = Integer.parseInt(str3);
        System.out.println(date);


        System.out.println(str.length());//是length()一个方法,不是.length
        System.out.println(str.equals(str2));
        System.out.println(str.compareTo(str2));
        System.out.println(str.compareToIgnoreCase(str2));
        System.out.println(str.charAt(2));
        System.out.println(str.indexOf('o'));
        System.out.println(str2.indexOf("el"));
        System.out.println(str.indexOf('o',2));


        StringBuffer stringBuffer = new StringBuffer("hello");

        System.out.println(stringBuffer.reverse());

    }
}
